import { NextResponse } from 'next/server';
import blogModule from '@/modules/blog';
import templates from '@/template/blogs/config'

export async function GET(request, { params }) {
  const { id } = await params;
  const codeMap = { 0: '获取成功', 1: '内容为空' };
  const blog = await blogModule.getById(Number(id));
  if (!blog) { return NextResponse.json({ code: 1, codeMap, message: 'No articles found' }); }
  return NextResponse.json({ code: 0, codeMap, message: 'Success', data: { ...blog, templates } });
}